<template>
    <div class="baoxiao">
        <p>报销申请</p>
        <el-form :model="ruleForm" 
        :rules="rules" 
        ref="ruleForm" 
        label-width="100px" 
        class="demo-ruleForm">
  <el-form-item label="报销名称" prop="name">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>
  <el-form-item label="报销类型" prop="region">
    <el-select v-model="ruleForm.region" placeholder="请选择报销类型">
      <el-option label="差旅" value="shanghai"></el-option>
      <el-option label="订购" value="beijing"></el-option>
      <el-option label="活动" value="beijing"></el-option>

    </el-select>
  </el-form-item>
  <el-form-item label="活动时间" required>
    <el-col :span="11">
      <el-form-item prop="date1">
        <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date1" style="width: 100%;"></el-date-picker>
      </el-form-item>
    </el-col>

  </el-form-item>

  <el-form-item label="报销性质" prop="type">
    <el-checkbox-group v-model="ruleForm.type">
      <el-checkbox label="出差" name="type"></el-checkbox>
      <el-checkbox label="单位活动" name="type"></el-checkbox>
      <el-checkbox label="采购" name="type"></el-checkbox>
      <el-checkbox label="招待" name="type"></el-checkbox>
    </el-checkbox-group>
  </el-form-item>
 
  <el-form-item label="报销详情" prop="desc">
    <el-input type="textarea" v-model="ruleForm.desc"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">申请</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</div>
</template>


<script>
export default {
    data() {
      return {
        ruleForm: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        rules: {
          name: [
            { required: true, message: '请输入报销名称', trigger: 'blur' },
            { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '请选择报销类型区域', trigger: 'change' }
          ],
          date1: [
            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          ],
         
          type: [
            { type: 'array', required: true, message: '请至少选择一个报销性质', trigger: 'change' }
          ],
        
          desc: [
            { required: true, message: '请填写报销详情', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('申请成功');
          } else {
            console.log('错误');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>
<style>
.baoxiao{
 width: 1200px;
 margin: 0 auto;
}

.baoxiao p{
 text-align: center;
 font-size: 20px;
}

.el-form-item{
 margin-bottom: 50px;
 
}
</style>